<template>
  <div class="application-list">
    <leave-crud title="应用" :url="url" :searchOption="searchOption">
      <template slot="tableRows">
        <el-table-column prop="name" label="应用名称"></el-table-column>
        <el-table-column prop="accessKey" label="密钥"></el-table-column>
        <el-table-column prop="user.name" label="所属用户"></el-table-column>
        <el-table-column prop="spm" label="用途">
          <template slot-scope="props">
            {{ spm[props.row.spm] || '公共'}}
          </template>
        </el-table-column>
        <el-table-column prop="expiredAt" label="到期日期">
          <template slot-scope="props">
            {{ dateFormat(props.row.expiredAt, 'yyyy-mm-dd') }}
          </template>
        </el-table-column>
        <el-table-column prop="createdAt" label="创建时间" min-width="110px">
          <template slot-scope="props">
            {{ props.row.createdAt | date }}
          </template>
        </el-table-column>
      </template>
    </leave-crud>
  </div>
</template>


<script>
  export default {
    name: 'application-list',
    data() {
      return {
        url: '/application',
        searchOption: [
          {
            'key': 'name',
            'label': '应用名称',
          },
          {
            'key': 'accessKey',
            'label': '密钥',
          },
          {
            'key': 'user.name',
            'label': '所属用户',
          },
        ],
        spm: {
          0: '用户认证',
          1: '服务器认证',
          2: '外部应用',
        },
      }
    },
    methods: {
      // 模块过滤
      filterModule(value, row) {
        return row.module.includes(value)
      },
    },
    created() {},
  }
</script>


<style lang="scss">
  .application-list {
  }
</style>
